<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>厂商账号详情</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div>
    <div>
        <div >
            <form id="formSet1">
                <div class="fieldset1 tabel_col clearFix">
					<div class="fieldBox col_50">
						<div class="label">账号类型</div>
						<div class="field">
							<span id="bizTypCdNm" name="bizTypCdNm"></span>
						</div>
					</div>
                    <div class="fieldBox col_50">
	                    <div class="label">收款方</div>
	                    <div class="field">
	                    	<span id="rcptUnt" name="rcptUnt"></span>
	                    </div>
	                </div>
                    <div class="fieldBox col_50">
	                    <div class="label">收款账号</div>
	                    <div class="field">
	                    	<span id="accNo" name="accNo"></span>
	                    </div>
	                </div>
                    <div class="fieldBox col_50">
	                    <div class="label">开户行</div>
	                    <div class="field">
	                    	<span id="bkNm" name="bkNm"></span>
	                    </div>
	                </div>
                    <div class="fieldBox col_50">
	                    <div class="label">开户行行号</div>
	                    <div class="field">
	                    	<span id="bkNo" name="bkNo"></span>
	                    </div>
	                </div>
					<c:if test="${bizTypCd != 0}">
						<div class="fieldBox col_50">
							<div class="label">银行预留手机号</div>
							<div class="field">
								<span id="bkResTel" name="bkResTel"></span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">收款方身份证号</div>
							<div class="field">
								<span id="certNo" name="certNo"></span>
							</div>
						</div>
					</c:if>
					<div class="fieldBox col_50">
						<div class="label">联系方式</div>
						<div class="field">
							<span id="contTel" name="contTel"></span>
						</div>
					</div>
                    <div class="fieldBox col_50">
	                    <div class="label">区域</div>
	                    <div class="field">
	                    	<span id="rgnNms" name="rgnNms"></span>
	                    </div>
	                </div>
	                <div class="fieldBox col_50">
	                    <div class="label">账户用途</div>
	                    <div class="field">
	                    	<span id="purpCdNm" name="purpCdNm"></span>
	                    </div>
	                </div>
	                <div class="fieldBox col_100">
	                    <div class="label">备注</div>
	                    <div class="field">
	                    	<span id="bkRem" name="bkRem"></span>
	                    	<input name="bkId" id="bkId" type="hidden" value="${id }">
	                    </div>
	                </div>
	                <c:if test="${isFlow==1 }">
		                <div class="fieldBox col_100">
		                    <div class="label">厂商</div>
		                    <div class="field">
		                    	<a href="javascript:showSplDetail()" class="link">
	                    			<span id="mfrNm" name="mfrNm">${mfrNm}</span>
		                    	</a>
		                    	<input name="mfrId" id="mfrId" type="hidden" value="${mfrId }">
		                    </div>
		                </div>
	                </c:if>
					<div class="splBizFlowPanel">
						<div class="fieldset1 tabel_col clearFix">
							<div class="sqPanel">
								<div class="sqPanel_head inL">
									<span>账号资料信息</span>
									<span class="btns"><span class="sq-button sq-button-round" onclick="downloadSplFileByUrl();">打包下载</span></span>
								</div>
								<div class="sqPanel_body">
									<div id="mfrAccFileInfoCfgGrid" class="sq-grid"></div>
								</div>
							</div>
						</div>
					</div>
                </div>
            </form>
        </div>
    </div>
</div>
</div>


<script type="text/javascript">

    var mfrAccFileInfoCfgGrid = null ;
    var isCheckVerify = '${isCheckVery}' ;
    var isFlow = '${isFlow}';
    var bizTypCd  = null ;
    var _cfgSysCd ; //附件系统CODE
    var _cfgOrgCd ; //附件组织架构
    var _tabNm ; //附件对应表
    var _cfgCd ; //附件CODE
    var _modulePath ;
    var _costomerPath ;
    var _rootPath ;
    var _uploadSysCd ;
    var _mfrBankAccId = '${id}';
    var serverPrefixPath = '';

	$(function(){

        //获取服务器路径前缀
        $.ajax({
            type: 'get',
            url: '<%=path%>/system/sysulfilesrec/getServerPath.do',
            success:function(msg){
                serverPrefixPath = msg;
                console.log(serverPrefixPath);
            }
        });

		var formSet1 = $('#formSet1').ligerForm({
				validate : true
		});

        mfrAccFileInfoCfgGrid = $("#mfrAccFileInfoCfgGrid").ligerGetGridManager();

		initData();

        mfrAccFileInfoCfgGrid = $("#mfrAccFileInfoCfgGrid").ligerGrid({
            url: '<%=path%>/product/splApplyInfo/initSplApplyFileInfoList.do',//?applyId='+_mfrBankAccId+'&cfgCd='+_cfgCd +'&tabNm='+_tabNm +"&cfgSysCd="+_cfgSysCd+'&cfgOrgCd='+_cfgOrgCd+'&uploadSysCd='+_uploadSysCd,
            method: 'get',
            parms: {applyId: _mfrBankAccId,cfgCd:_cfgCd,tabNm: _tabNm,cfgSysCd:_cfgSysCd,uploadSysCd:_uploadSysCd},
            columns: [
                {display: '资料名称', name: 'datNm',align: 'left', minWidth: 100, enabledSort: false},
                {display: '上传文件名称', name: 'fileNm',align: 'left', minWidth: 100, enabledSort: false,
                    render:function(rowdata,rowindex,value){
                        if(value){
                            var h;
                            h='<a href="javascript:uploadFileByUrl(';
                            h+="'"+rowdata.filePath+"'";
                            h+=",'"+rowdata.fileNm+"'";
                            h+=')">'+rowdata.fileNm+'</a>'
                            return h;
                        }
                    }
                },
                {display: '上传文件路径', name: 'filePath',align: 'left', minWidth: 100,hide:true},
                {display: '上传文件明细', name: 'cfgDtlCd',align: 'left', minWidth: 100,hide:true},
                {display: '上传时间', name: 'crtTm',align: 'left', minWidth: 100, enabledSort: false,render:renderDate},
                {display: '状态', name: 'audStsCdNm', width: 100, enabledSort: false},
                {display: '操作', name: '', minWidth: 200,align: 'left',  enabledSort: false,
                    render:function(rowdata,rowindex,value){
                        var h='';
                        if(rowdata.audStsCd){
                            if(rowdata.audStsCd !=1){
                                if(isFlow && rowdata.fileId && isFlow && isFlow == 1){
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',1);"><i class="sqBtnIco_15"></i>验证通过</a>';
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',2);"><i class="sqBtnIco_14"></i>验证不通过</a>';
                                }
                            }
                        }
                        return h;
                    }
                },
                {display: '上传', name: 'uploadNm', width: 80,align: 'left', enabledSort: false,
                    render:function(rowdata,rowindex,value){
                        var h='';
                        return h;
                    }
                },
            ],
            root: 'rows',
            hideLoadButton : true,
            width: '100%',
            height: '100%',
            isScroll: false,
            rownumbers:true,  //显示序号
            checkbox: false,
            allowUnSelectRow:true,
            alternatingRow: false,
            frozen: false,
            usePager: false,
            onAfterShowData: function ()
            {
                $('#mfrAccFileInfoCfgGrid').rowspan('datNm');
                $('#mfrAccFileInfoCfgGrid').rowspan('uploadNm');
            },
        });
	});

	//定义父级调用事件
	frameElement.dialog.onCancel = function () {
	    frameElement.dialog.close();
	}

	function initData(){
		var id = $("#bkId").val();
    	if(!id)return;
    	var _url = '<%=path%>/mfr/mfrbankacc/getById.do';
    	$.ajax({
    		type: 'get',
    		dataType:'json',
    		data:{id:id},
    		url: _url,
    		success:function(msg){
    			 if(msg.success == 1){
    				 setData(msg.data);//设置数据
                     bizTypCd = msg.data.mfrBankAccVO.bizTypCd ;
    			 }else{
    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
    			 }
    		}
    	});
   	}
		
	//设置页面数据
    function setData(data){
    	var form = liger.get("formSet1");
    	$("#rcptUnt").html(data.mfrBankAccVO.rcptUnt);
    	$("#accNo").html(data.mfrBankAccVO.accNo);
    	$("#bkNm").html(data.mfrBankAccVO.bkNm);
    	$("#bkNo").html(data.mfrBankAccVO.bkNo);
    	$("#bkRem").html(data.mfrBankAccVO.bkRem);
    	$("#rgnNms").html(data.mfrBankAccVO.rgnNms);
    	$("#bizTypCdNm").html(data.mfrBankAccVO.bizTypCdNm);
    	$("#purpCdNm").html(data.mfrBankAccVO.purpCdNm);
    	$("#contTel").html(data.mfrBankAccVO.contTel);
        $("#certNo").html(data.mfrBankAccVO.certNo);
        $("#bkResTel").html(data.mfrBankAccVO.bkResTel);

        _cfgSysCd = data.cfgSysCd; //附件系统CODE
        _cfgOrgCd = data.cfgOrgCd; //附件组织架构
        _tabNm = data.tabNm; //附件对应表
        _cfgCd = data.cfgCd; //附件CODE
        _modulePath = data.modulePath;
        _costomerPath = data.costomerPath;
        _rootPath = data.rootPath;
        _uploadSysCd = data.uploadSysCd;
        _mfrBankAccId = data.id;

        mfrAccFileInfoCfgGrid.setParm("cfgSysCd",_cfgSysCd);
        mfrAccFileInfoCfgGrid.setParm("cfgCd",_cfgCd);
        mfrAccFileInfoCfgGrid.setParm("tabNm",_tabNm);
        mfrAccFileInfoCfgGrid.setParm("cfgSysCd",_cfgSysCd);
        mfrAccFileInfoCfgGrid.setParm("uploadSysCd",_uploadSysCd);
        mfrAccFileInfoCfgGrid.reload();
	};
	
	function showSplDetail(){
		var mfrId = $("#mfrId").val();
		if(StringUtils.isNotEmpty(splId)){
			Add_navTab('splInfo'+splId,'厂商详情','<%=path%>/mfr/mfrBscInfo/toDetailPage.do?id='+mfrId);
		}
	}

    //修改资料的验证状态
    function modifyAudStsCd(event,_fileId,_audStsCd){
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {'fileId':_fileId,'audStsCd':_audStsCd},
            url: '<%=path%>/product/splInfo/modifyFileAudStsCd.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    //$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    event.stopPropagation();
                    var gridID = $(event.target).parents('.sq-grid').attr('ligeruiid');
                    liger.get(gridID).reload();
                }else{
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    function uploadFileByUrl(_url,_name){
        if(serverPrefixPath.length >1 && serverPrefixPath.indexOf("\"")>=0){
            serverPrefixPath = serverPrefixPath.substring(1,serverPrefixPath.length-1);
        }
        if(SQ.regs.img.test(_name)){
            if(_url.indexOf('http') != -1){
                window.__ImgSrc =  _url;
            }else{
                window.__ImgSrc = serverPrefixPath + _url;
            }
            // window.__ImgSrc = serverPrefixPath + _url;
            window.__ImgTit = _name;
            window.open('<%=path%>/project/prjbscinfo/imgWinOpen.do', _name, 'location=yes, width=800, height=600');
        }else{
            if(_url.indexOf('http') != -1){
                window.open( _url);
            }else{
                window.open(serverPrefixPath + _url);
            }
        }
    }

</script>



</body>
</html>
